<style lang="scss" scoped>
  @import '../../styles/common/loading.less';
  .container{
    border: none !important;
    margin-top: 4px;
  }
  .el-col-offset-1 {
    margin-left: 0%;
  }
  .button_a {
    background-color: rgba(255, 138, 0, 1);
    border-color: rgba(255, 138, 0, 1);

  }
  .col_a {
    margin-left: 2%;
  }
  .el-card {
    height: 200px;
  }

  .el-button--primary {
    background-color: rgba(255, 138, 0, 1);
    border-color: rgba(255, 138, 0, 1);
  }
</style>
<template>
    <div>
        <div class="container">
            <div>
                <el-form :model="formInline" class="select-submit-form">
                    <el-row type="flex" >
                        <el-col :span="8">
                            <el-form-item label="疾病编码">
                                <el-input  v-model="formInline.diseCode"></el-input>
                            </el-form-item>
                        </el-col>
                      <el-col :span="8" >
                        <el-form-item label="疾病名称" >
                          <el-input  v-model="formInline.diseName"></el-input>
                        </el-form-item>
                      </el-col>
                      <el-col :span="8" >
                        <el-form-item label="拼音助记码">
                          <el-input v-model="formInline.pinyinCode"></el-input>
                        </el-form-item>
                      </el-col>
                    </el-row>
                    <el-row type="flex" >
                        <el-col :span="8">
                            <el-form-item label="病种类别">
                                <el-select   v-model="formInline.diseType">
                                  <el-option
                                    v-for="item in DiseType"
                                    :key="item.codeCode"
                                    :label="item.codeCName"
                                    :value="item.codeCode">
                                  </el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                      <el-col :span="8">
                        <el-form-item label="疾病种类">
                          <el-select   v-model="formInline.diseClass">
                            <el-option
                              v-for="item in DiseClass"
                              :key="item.codeCode"
                              :label="item.codeCName"
                              :value="item.codeCode">
                            </el-option>
                          </el-select>
                        </el-form-item>
                      </el-col>
                      <el-col :span="8" >
                        <el-form-item label="有效标识">
                          <el-select   v-model="formInline.delFlag">
                            <el-option value="" label="请选择"></el-option>
                            <el-option
                              v-for="item in ValidFlag"
                              :key="item.codeCode"
                              :label="item.codeCName"
                              :value="item.codeCode">
                            </el-option>
                          </el-select>
                        </el-form-item>
                      </el-col>
                    </el-row>
                    <el-row>
                      <el-col :span="24">
                        <div class="select-btn-group">
                          <el-button type="primary" size="medium"  @click="onSubmitBzmlgl">查询</el-button>
                          <el-button type="primary" size="medium" @click="handleReset">重置</el-button>
                          <el-button type="primary" size="medium" @click="save()" >增加</el-button>
                        </div>
                      </el-col>
                    </el-row>
                </el-form>
                <el-table
                    :data="list"
                    class="table"
                    ref="multipleTable"
                    header-cell-class-name="table-header"
                    style="margin: 30px 0;border: 1px solid #d6d9d8;"
                    v-loading="loading"
                    element-loading-text="Loading....."
                >
                    <el-table-column type="index" label="序号" width="55" align="center"></el-table-column>
                    <el-table-column prop="comCode" label="创建机构编码" align="center"></el-table-column>
                    <el-table-column prop="diseCode" label="疾病编码" align="center"></el-table-column>
                    <el-table-column prop="diseName" label="疾病名称" align="center"></el-table-column>
                    <el-table-column prop="pinyinCode" label="拼音助记码" align="center"></el-table-column>
                    <el-table-column prop="diseTypeName" :formatter="diseTypeNameFormat" label="病种类别" align="center"></el-table-column>
                    <el-table-column prop="deductibleDiseFlag" label="免赔病种标识"  :formatter="deductibleDiseFlagFormat" align="center"></el-table-column>
                    <el-table-column prop="startDate" label="开始日期" :width="150" align="center"></el-table-column>
                    <el-table-column prop="endDate" label="终止日期" :width="150" align="center"></el-table-column>
                    <el-table-column prop="delFlag"   :formatter="delFlagFormat" label="有效标志" align="center"></el-table-column>
                    <el-table-column label="操作" width="180" align="center">
                      <template slot-scope="scope">
                        <el-button
                          size="mini"
                          type="text"
                          @click="handleLook(scope.$index, scope.row)">查看</el-button>
                        <el-button
                          size="mini"
                          type="text"
                          @click="handleEdit(scope.$index, scope.row)">修改</el-button>
                        <el-button
                          size="mini"
                          type="text"
                          @click="handleDelete(scope.$index, scope.row)">删除</el-button>
                      </template>
                    </el-table-column>
                </el-table>
              <div class="pagination" v-if="this.list.length!==0">
                <div class="index_page">
                  <el-pagination :current-page="pagination.currentPage" :page-size="pagination.rowsNumber"
                                 :page-sizes="[10, 20, 50, 100]"
                                 :total="pagination.totalPage" background layout="prev, pager, next,sizes,total,jumper"
                                 @size-change="handleSizeChange" @current-change="queryFun">
                  </el-pagination>
                </div>
              </div>
            </div>
        </div>
    </div>
</template>
<script>
import * as api from '@/api/basicInformation'
import * as api1 from '@/api/baseDate'
export default {
    name: 'baseform',
    data() {
        return {
          loading: false,
          pagination: {
            currentPage: 1, // 当前页
            rowsNumber: 10, // 每页条数
            totalPage: 0 // 总条数
          },
          ValidFlag:[
            {
              codeCode:0,
              codeCName:'无效'
            },
            {
              codeCode:1,
              codeCName:'有效'
            },
          ],
          DiseClass:[],
          DiseType:[],
          SpeDiseClass:[],
          formInline:{
            comCode:'',
            diseCode:'',
            diseName:'',
            pinyinCode:'',
            diseType:'',
            diseClass:'',
            delFlag:'',
          },
          checkList: ['急诊'],
          props: { multiple: true },
          dialogFormVisible: false,
          dialogFormVisibleUpdate: false,
          list:[],
          tableData: [],
          form: {},
          item:0,
          ailmentCatalogDemo:{},
          formUpdate: {}
        };
    },
  created() {
    this.DiseType1(),
    this.DiseClass1(),
    this.SpeDiseClass1(),
    this.onSubmitBzmlgl();
  },
  methods: {
    delFlagFormat(row, column) {
      let delFlag = row.delFlag
      if (delFlag === 0) {
        return '无效'
      } else if (delFlag === 1) {
        return '有效'
      }
    },
    diseTypeNameFormat(row, column) {
      let diseTypeName = row.delFlag
      if (diseTypeName === 0) {
        return '普通病种'
      } else if (diseTypeName === 1) {
        return '门诊大病'
      }
    },
    deductibleDiseFlagFormat(row, column) {
      let deductibleDiseFlag = row.delFlag
      if (deductibleDiseFlag === 0) {
        return '是'
      } else if (deductibleDiseFlag === 1) {
        return '否'
      }
    },
    handleSizeChange(pageSize){ // 改变当前页条数事件
      this.pagination.rowsNumber=pageSize
      this.onSubmitBzmlgl();
      /* let pageIndex = this.pagination.currentPage;
       this.querySettleAuditTaskList(pageIndex,pageSize);*/
    },
    queryFun(pageNum){ // 改变当前页事件
      this.pagination.currentPage=pageNum
      this.onSubmitBzmlgl();
      /* let rowsNumber = this.pagination.rowsNumber;
       this.querySettleAuditTaskList(pageNum,rowsNumber);*/
    },
      // 添加
    save(){
      this.$router.push({
        name: 'ailmentCatalogDemo',
        query: {
          ailmentCatalogDemo: JSON.stringify(this.ailmentCatalogDemo),
          item: JSON.stringify(0),
        }
      })
    },
    // 按条件查询
    onSubmitBzmlgl() {
      var data = {
        "comCode":this.formInline.comCode,
        "diseCode":this.formInline.diseCode,
        "diseName":this.formInline.diseName,
        "pinyinCode":this.formInline.pinyinCode,
        "diseType":this.formInline.diseType,
        "diseTypeName":this.formInline.diseTypeName,
        "diseClass":this.formInline.diseClass,
        "delFlag":this.formInline.delFlag,
        "pageNum":this.pagination.currentPage,
        "pageSize":this.pagination.rowsNumber,
      }
      this.loading = true;
      api.getQueryDisease(data
      ).then(res => {
        this.loading = false;
        if(res){
            if(res.data.resultCode !== '0000'){
                this.$message.error(res.data.resultMsg);
            }else{
                this.list = res.data.list;
                this.pagination.totalPage=res.data.total;
            }
        }else{
            this.$message.error('系统异常');
        }
      })
    },
    // 重置
    handleReset(){

    },
    // 查看
    handleLook(index,row){
      this.ailmentCatalogDemo=row,
      this.$router.push({
        name: 'ailmentCatalogDemo',
        query: {
          ailmentCatalogDemo: JSON.stringify(this.ailmentCatalogDemo),
          item: JSON.stringify(2),
        }
      })
    },
    // 修改
    handleEdit(index,rew){
      this.ailmentCatalogDemo=rew,
        this.$router.push({
          name: 'ailmentCatalogDemo',
          query: {
            ailmentCatalogDemo: JSON.stringify(this.ailmentCatalogDemo),
            item: JSON.stringify(1),
          }
        })
    },
    // 删除
    handleDelete(index,rew){
      var data={
        "id":rew.id,
      }
      api.getDeleteDisease(data
      ).then(res => {
        if(res.data.resultCode){
          if(res.data.resultCode !== '0000'){
            this.$message.error(res.data.resultMsg);
          }else{
            this.$message.success(res.data.resultMsg);
          }
        }
        this.reload();
      })
    },
    //疾病分类
    DiseClass1(){
      var data={
        "codeType": "DiseClass"
      }
      api1.MedType(data
      ).then(res => {
        // debugger
        this.DiseClass=res.data
      })
    },
    //病种类别SpeDiseClass
    DiseType1(){
      var data={
        "codeType": "DiseType"
      }
      api1.MedType(data
      ).then(res => {
        // debugger
        this.DiseType=res.data
      })
    },
    //病种类别
    SpeDiseClass1(){
      var data={
        "codeType": "SpeDiseClass"
      }
      api1.MedType(data
      ).then(res => {
        // debugger
        this.SpeDiseClass=res.data
      })
    },
        onSubmit() {
            this.$message.success('提交成功！');
        },
        // 分页导航
        handlePageChange(val) {
            this.$set(this.query, 'pageIndex', val);
            this.getData();
        },
    }
};
</script>